<template>
	<view class="content">
		<view>
			<text>高德相关</text>
			<button @click="getLocation">定位信息</button>
			<text>{{address}}</text>
		</view>
		
		<view>
			<text>腾讯地图相关</text>
			<button @click="getLocationQQ">QQ定位信息</button>
		</view>
	</view>
</template>

<script>
	import amap from '../../common/amap-wx.130.js';
	import QQMapWX from "../../common/qqmap-wx-jssdk.js";
	
	export default {
		data() {
			return {
				amapPlugin: null, 
				key: 'b6717d96baa1f12d9972459038571dc0',
				address: '',
				
				qqmapPlugin: null,
				qqKey: 'QBSBZ-CQNEI-FDRGI-U2K2D-KS3KE-QNFFR',
				qqAddress: '',
			}
		},
		onLoad() {  
			this.amapPlugin = new amap.AMapWX({  
				key: this.key  
			});
			this.qqmapPlugin = new QQMapWX({
				key: qqKey
			});

		},
		methods: {
			getLocation() {
				uni.showLoading({  
					title: '获取信息中'  
				});  
				this.amapPlugin.getRegeo({  
					success: (data) => {  
						console.log(data)  
						this.address = data[0].name
						uni.hideLoading();  
					}  
				});  
			},
			
			getLocationQQ() {
			},
			openLocation() {
				uni.getLocation({
					type: 'gcj02', //返回可以用于uni.openLocation的经纬度
					success: function (res) {
						const latitude = res.latitude;
						const longitude = res.longitude;
						uni.openLocation({
							latitude: latitude,
							longitude: longitude,
							success: function () {
								console.log('success');
							}
						});
					}
				});
			}
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
